package problem300;

import java.util.Arrays;

//300. 最长递增子序列
//https://leetcode.cn/problems/longest-increasing-subsequence/description/
//动态规划解法

public class Solution2 {
    public int lengthOfLIS(int[] nums) {
        int n = nums.length;
        int[] dp = new int[n];
        Arrays.fill(dp, 1);
        int ret = 0;
        for(int i = 0; i<n; i++) {
            for(int j = 0; j<i; j++) {
                if(nums[i] > nums[j]) {
                    dp[i] = Math.max(dp[i], dp[j]+1);
                }
            }
            ret = Math.max(ret, dp[i]);
        }
        return ret;
    }
}
